package com.itheima.jujue;

import java.util.concurrent.*;

public class Demo01 {

    public static void main(String[] args) {
        /*
        核心线程数 ,最大线程数,空闲时间数,空闲时间单位
        阻塞队列,线程工厂,拒绝策略
         */
        ThreadPoolExecutor pool = new ThreadPoolExecutor(
                2,
                3,
                60,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(1),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy());//丢弃并抛异常
        for (int i = 0; i < 10; i++) {
            pool.submit(()->{
                System.out.println(Thread.currentThread().getName()+"执行了");
            });
        }
    }
}
